﻿using System;
using System.IO;
using Microsoft.Win32;

namespace ConvergensSettings
{
    public abstract class SettingsBase
    {
        protected string sdhServerName = string.Empty;
        protected string mailServerName = string.Empty;
        protected string databasePath = string.Empty;

        #region MailItem
        protected string sentOn = string.Empty;
        protected string senderName = string.Empty;
        protected string senderEmailAddress = string.Empty;
        protected string sentOnBehalfOfName = string.Empty;
        protected string receivedTime = string.Empty;
        protected string receivedByName = string.Empty;
        protected string receivedOnBehalfOfName = string.Empty;
        protected string replyRecipientNames = string.Empty;
        protected string resolvedSenderEmailAdress = string.Empty;
        protected string subject = string.Empty;
        protected string to = string.Empty;
        protected string bcc = string.Empty;
        protected string cc = string.Empty;
        protected string body = string.Empty;
        protected string bodyFormat = string.Empty;
        protected string eml = string.Empty;
        protected string msg = string.Empty;
        protected string entryID = string.Empty;
        protected string form = string.Empty;
        protected string saveAsType = string.Empty;
        protected string journalizeToUserMailDb = string.Empty;
        protected string conversationID = string.Empty;
        #endregion MailItem

        #region ReportItem
        protected string rptItm_SaveAsType = string.Empty;
        protected string rptItm_Form = string.Empty;
        protected string rptItm_BCC = string.Empty;
        protected string rptItm_Body = string.Empty;
        protected string rptItm_CreationTime = string.Empty;
        protected string rptItm_CC = string.Empty;
        protected string rptItm_EMLBody = string.Empty;
        protected string rptItm_EntryID = string.Empty;
        protected string rptItm_MSGBody = string.Empty;
        protected string rptItm_Subject = string.Empty;
        protected string rptItm_To = string.Empty;
        protected string rptItm_From = string.Empty;
        protected string rptItm_ConversationID = string.Empty;
        protected string rptItm_ReceivedByName = string.Empty;
        protected string rptItm_ReceivedOnBehalfOfName = string.Empty;
        protected string rptItm_ReplyRecipientNames = string.Empty;
        protected string rptItm_ResolvedSenderEmailAdress = string.Empty;
        protected string rptItm_SenderEmailAddress = string.Empty;
        protected string rptItm_SenderName = string.Empty;
        protected string rptItm_SentOnBehalfOfName = string.Empty;
        #endregion
        
        #region MeetingItem
        protected string mtgItm_SaveAsType = string.Empty;
        protected string mtgItm_Form = string.Empty;
        protected string mtgItm_BCC = string.Empty;
        protected string mtgItm_Body = string.Empty;
        protected string mtgItm_CreationTime = string.Empty;
        protected string mtgItm_CC = string.Empty;
        protected string mtgItm_EMLBody = string.Empty;
        protected string mtgItm_EntryID = string.Empty;
        protected string mtgItm_MSGBody = string.Empty;
        protected string mtgItm_Subject = string.Empty;
        protected string mtgItm_To = string.Empty;
        protected string mtgItm_From = string.Empty;
        protected string mtgItm_ConversationID = string.Empty;
        protected string mtgItm_ReceivedByName = string.Empty;
        protected string mtgItm_ReceivedOnBehalfOfName = string.Empty;
        protected string mtgItm_ReplyRecipientNames = string.Empty;
        protected string mtgItm_ResolvedSenderEmailAdress = string.Empty;
        protected string mtgItm_SenderEmailAddress = string.Empty;
        protected string mtgItm_SenderName = string.Empty;
        protected string mtgItm_SentOnBehalfOfName = string.Empty;
        #endregion

        #region JournalizeSingle
        protected string jnalSgl_CbSDH = string.Empty;
        protected string jnalSgl_TbCaseNum = string.Empty;
        protected string jnalSgl_Lbtitle = string.Empty;
        protected string jnalSgl_RbMustReply = string.Empty;
        protected string jnalSgl_TbSeqNum = string.Empty;
        protected string jnalSgl_CbRplyReq = string.Empty;
        protected string jnalSgl_CbCaseOfr = string.Empty;
        protected string jnalSgl_LbMailRightSelected = string.Empty;
        protected string jnalSgl_TbDocName = string.Empty;
        protected string jnalSgl_TbRemarks = string.Empty;
        protected string jnalSgl_CbCaseParts = string.Empty;
        protected string jnalSgl_CbFreeCat = string.Empty;
        protected string jnalSgl_LbCaseArea = string.Empty;
        protected string jnalSgl_LbEdction = string.Empty;
        protected string jnalSgl_LbInstitution = string.Empty;
        protected string jnalSgl_LbLeglAspcts = string.Empty;
        protected string jnalSgl_LbEcoAspcts = string.Empty;
        #endregion

        #region ControlCheckAgent
        protected string controlCheckAgentName = string.Empty;
        protected string controlCheckAgentControlField = string.Empty;
        #endregion

        #region PostJournalizeAgent
        protected string postJournalizeAgentAgentName = string.Empty;
        protected string postJournalizeAgentControlField = string.Empty;
        #endregion

        protected SettingsBase() { }

        public abstract void Load();
        public abstract void Save();

        public string SDHServerName
        {
            get { return sdhServerName; }
            set { sdhServerName = value; }
        }

        public string DatabasePath
        {
            get { return databasePath; }
            set { databasePath = value; }
        }

        public string MailServerName
        {
            get { return mailServerName; }
            set { mailServerName = value; }
        }

        #region MailItem
        public string SentOn
        {
            get { return sentOn; }
            set { sentOn = value; }
        }

        public string SenderName
        {
            get { return senderName; }
            set { senderName = value; }
        }

        public string SenderEmailAddress
        {
            get { return senderEmailAddress; }
            set { senderEmailAddress = value; }
        }

        public string SentOnBehalfOfName
        {
            get { return sentOnBehalfOfName; }
            set { sentOnBehalfOfName = value; }
        }

        public string ReceivedTime
        {
            get { return receivedTime; }
            set { receivedTime = value; }
        }

        public string ReceivedByName
        {
            get { return receivedByName; }
            set { receivedByName = value; }
        }

        public string ReceivedOnBehalfOfName
        {
            get { return receivedOnBehalfOfName; }
            set { receivedOnBehalfOfName = value; }
        }

        public string ReplyRecipientNames
        {
            get { return replyRecipientNames; }
            set { replyRecipientNames = value; }
        }

        public string ResolvedSenderEmailAdress 
        {
            get { return resolvedSenderEmailAdress; }
            set { resolvedSenderEmailAdress = value; }
        }

        public string Subject
        {
            get { return subject; }
            set { subject = value; }
        }

        public string To
        {
            get { return to; }
            set { to = value; }
        }

        public string Cc
        {
            get { return cc; }
            set { cc = value; }
        }

        public string Bcc
        {
            get { return bcc; }
            set { bcc = value; }
        }

        public string Body
        {
            get { return body; }
            set { body = value; }
        }

        public string BodyFormat
        {
            get { return bodyFormat; }
            set { bodyFormat = value; }
        }

        public string Eml
        {
            get { return eml; }
            set { eml = value; }
        }

        public string Msg
        {
            get { return msg; }
            set { msg= value; }
        }

        public string EntryID
        {
            get { return entryID; }
            set { entryID = value; }
        }

        public string Form
        {
            get { return form; }
            set { form = value; }
        }

        public string SaveAsType
        {
            get { return saveAsType; }
            set { saveAsType = value; }
        }

        public string JournalizeToUserMailDb
        {
            get { return journalizeToUserMailDb; }
            set { journalizeToUserMailDb = value; }
        }

        public string ConversationID
        {
            get { return conversationID; }
            set { conversationID = value; }
        }
#endregion

        #region ReportItem
        public string RptItm_SaveAsType 
        {
            get { return rptItm_SaveAsType; }
            set { rptItm_SaveAsType = value; }
        }

        public string RptItm_Form
        {
            get { return rptItm_Form; }
            set { rptItm_Form = value; }
        }

        public string RptItm_BCC 
        {
            get { return rptItm_BCC; }
            set { rptItm_BCC = value; }
        }

        public string RptItm_Body 
        {
            get { return rptItm_Body; }
            set { rptItm_Body = value; }
        }

        public string RptItm_CreationTime 
        {
            get { return rptItm_CreationTime; }
            set { rptItm_CreationTime = value; }
        }

        public string RptItm_CC 
        {
            get { return rptItm_CC; }
            set { rptItm_CC = value; }
        }

        public string RptItm_EMLBody 
        {
            get { return rptItm_EMLBody; }
            set { rptItm_EMLBody = value; }
        }

        public string RptItm_EntryID 
        {
            get { return rptItm_EntryID; }
            set { rptItm_EntryID = value; }
        }

        public string RptItm_From
        {
            get { return rptItm_From; }
            set { rptItm_From = value; }
        }

        public string RptItm_MSGBody 
        {
            get { return rptItm_MSGBody; }
            set { rptItm_MSGBody = value; }
        }

        public string RptItm_Subject 
        {
            get { return rptItm_Subject; }
            set { rptItm_Subject = value; }
        }

        public string RptItm_To 
        {
            get { return rptItm_To; }
            set { rptItm_To = value; }
        }

        public string RptItm_ConversationID
        {
            get { return rptItm_ConversationID; }
            set { rptItm_ConversationID = value; }
        }

        public string RptItm_ReceivedByName
        {
            get { return rptItm_ReceivedByName; }
            set { rptItm_ReceivedByName = value; }
        }

        public string RptItm_ReceivedOnBehalfOfName
        {
            get { return rptItm_ReceivedOnBehalfOfName; }
            set { rptItm_ReceivedOnBehalfOfName = value; }
        }

        public string RptItm_ReplyRecipientNames
        {
            get { return rptItm_ReplyRecipientNames; }
            set { rptItm_ReplyRecipientNames = value; }
        }

        public string RptItm_ResolvedSenderEmailAdress
        {
            get { return rptItm_ResolvedSenderEmailAdress; }
            set { rptItm_ResolvedSenderEmailAdress = value; }
        }

        public string RptItm_SenderEmailAddress
        {
            get { return rptItm_SenderEmailAddress; }
            set { rptItm_SenderEmailAddress = value; }
        }

        public string RptItm_SenderName
        {
            get { return rptItm_SenderName; }
            set { rptItm_SenderName = value; }
        }

        public string RptItm_SentOnBehalfOfName
        {
            get { return rptItm_SentOnBehalfOfName; }
            set { rptItm_SentOnBehalfOfName = value; }
        }
        #endregion

        #region MeetingItem
        public string MtgItm_SaveAsType
        {
            get { return mtgItm_SaveAsType; }
            set { mtgItm_SaveAsType = value; }
        }

        public string MtgItm_Form
        {
            get { return mtgItm_Form; }
            set { mtgItm_Form = value; }
        }

        public string MtgItm_BCC
        {
            get { return mtgItm_BCC; }
            set { mtgItm_BCC = value; }
        }

        public string MtgItm_Body
        {
            get { return mtgItm_Body; }
            set { mtgItm_Body = value; }
        }

        public string MtgItm_CreationTime
        {
            get { return mtgItm_CreationTime; }
            set { mtgItm_CreationTime = value; }
        }

        public string MtgItm_CC
        {
            get { return mtgItm_CC; }
            set { mtgItm_CC = value; }
        }

        public string MtgItm_EMLBody
        {
            get { return mtgItm_EMLBody; }
            set { mtgItm_EMLBody = value; }
        }

        public string MtgItm_EntryID
        {
            get { return mtgItm_EntryID; }
            set { mtgItm_EntryID = value; }
        }

        public string MtgItm_From
        {
            get { return mtgItm_From; }
            set { mtgItm_From = value; }
        }

        public string MtgItm_MSGBody
        {
            get { return mtgItm_MSGBody; }
            set { mtgItm_MSGBody = value; }
        }

        public string MtgItm_Subject
        {
            get { return mtgItm_Subject; }
            set { mtgItm_Subject = value; }
        }

        public string MtgItm_To
        {
            get { return mtgItm_To; }
            set { mtgItm_To = value; }
        }

        public string MtgItm_ConversationID
        {
            get { return mtgItm_ConversationID; }
            set { mtgItm_ConversationID = value; }
        }

        public string MgtItm_ReceivedByName
        {
            get { return mtgItm_ReceivedByName; }
            set { mtgItm_ReceivedByName = value; }
        }

        public string MgtItm_ReceivedOnBehalfOfName
        {
            get { return mtgItm_ReceivedOnBehalfOfName; }
            set { mtgItm_ReceivedOnBehalfOfName = value; }
        }

        public string MgtItm_ReplyRecipientNames
        {
            get { return mtgItm_ReplyRecipientNames; }
            set { mtgItm_ReplyRecipientNames = value; }
        }

        public string MgtItm_ResolvedSenderEmailAdress
        {
            get { return mtgItm_ResolvedSenderEmailAdress; }
            set { mtgItm_ResolvedSenderEmailAdress = value; }
        }

        public string MgtItm_SenderEmailAddress
        {
            get { return mtgItm_SenderEmailAddress; }
            set { mtgItm_SenderEmailAddress = value; }
        }

        public string MgtItm_SenderName
        {
            get { return mtgItm_SenderName; }
            set { mtgItm_SenderName = value; }
        }

        public string MgtItm_SentOnBehalfOfName
        {
            get { return mtgItm_SentOnBehalfOfName; }
            set { mtgItm_SentOnBehalfOfName = value; }
        }
        #endregion

        #region JournalizeSingle
        public string JnalSgl_CbSDH 
        {
            get { return jnalSgl_CbSDH; }
            set { jnalSgl_CbSDH = value; }
        }

        public string JnalSgl_TbCaseNum 
        {
            get { return jnalSgl_TbCaseNum; }
            set { jnalSgl_TbCaseNum = value; }
        }

        public string JnalSgl_Lbtitle 
        {
            get { return jnalSgl_Lbtitle; }
            set { jnalSgl_Lbtitle = value; }
        }

        public string JnalSgl_RbMustReply 
        {
            get { return jnalSgl_RbMustReply; }
            set { jnalSgl_RbMustReply = value; }
        }

        public string JnalSgl_TbSeqNum 
        {
            get { return jnalSgl_TbSeqNum; }
            set { jnalSgl_TbSeqNum = value; }
        }

        public string JnalSgl_CbRplyReq 
        {
            get { return jnalSgl_CbRplyReq; }
            set { jnalSgl_CbRplyReq = value; }
        }

        public string JnalSgl_CbCaseOfr 
        {
            get { return jnalSgl_CbCaseOfr; }
            set { jnalSgl_CbCaseOfr = value; }
        }

        public string JnalSgl_LbMailRightSelected 
        {
            get { return jnalSgl_LbMailRightSelected; }
            set { jnalSgl_LbMailRightSelected = value; }
        }

        public string JnalSgl_TbDocName 
        {
            get { return jnalSgl_TbDocName; }
            set { jnalSgl_TbDocName = value; }
        }

        public string JnalSgl_TbRemarks 
        {
            get { return jnalSgl_TbRemarks; }
            set { jnalSgl_TbRemarks = value; }
        }

        public string JnalSgl_CbCaseParts 
        {
            get { return jnalSgl_CbCaseParts; }
            set { jnalSgl_CbCaseParts = value; }
        }

        public string JnalSgl_CbFreeCat 
        {
            get { return jnalSgl_CbFreeCat; }
            set { jnalSgl_CbFreeCat = value; }
        }

        public string JnalSgl_LbCaseArea 
        {
            get { return jnalSgl_LbCaseArea; }
            set { jnalSgl_LbCaseArea = value; }
        }

        public string JnalSgl_LbEdction 
        {
            get { return jnalSgl_LbEdction; }
            set { jnalSgl_LbEdction = value; }
        }

        public string JnalSgl_LbInstitution 
        {
            get { return jnalSgl_LbInstitution; }
            set { jnalSgl_LbInstitution = value; }
        }

        public string JnalSgl_LbLeglAspcts 
        {
            get { return jnalSgl_LbLeglAspcts; }
            set { jnalSgl_LbLeglAspcts = value; }
        }

        public string JnalSgl_LbEcoAspcts 
        {
            get { return jnalSgl_LbEcoAspcts; }
            set { jnalSgl_LbEcoAspcts = value; }
        }
















        #endregion

        #region ControlCheckAgent
        public string ControlCheckAgentName
        {
            get { return controlCheckAgentName; }
            set { controlCheckAgentName = value; }
        }

        public string ControlCheckAgentControlField
        {
            get { return controlCheckAgentControlField; }
            set { controlCheckAgentControlField = value; }
        }
        #endregion

        #region PostJournalizeAgent
        public string PostJournalizeAgentAgentName
        {
            get { return postJournalizeAgentAgentName; }
            set { postJournalizeAgentAgentName = value; }
        }
        public string PostJournalizeAgentControlField
        {
            get { return postJournalizeAgentControlField; }
            set { postJournalizeAgentControlField = value; }
        }
        #endregion

    }
    
    public class CDCOFileSettings : SettingsBase
    { 
        public static CDCOFileSettings SINGLETON = new CDCOFileSettings();
        public static CDCOFileSettings Instance
        {
            get { return SINGLETON; }
        }

        private CDCOFileSettings()
            : base() { }

        public void Reload()
        {
          
        }
        public override void Load()
        {
            DirectoryInfo directory = new DirectoryInfo(
                System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
                + "\\Convergens\\Convergens Domino Connector for SDH");
            if (!directory.Exists)
            {
                throw new Exception("Directory \"" + System.Reflection.Assembly.GetCallingAssembly().Location + "\" does not exist.");
            }

            string filePath = directory.FullName + "\\CDCOSDH.config";

            if (!File.Exists(filePath))
            {
                throw new Exception("File \"" + filePath + "\" does not exist.");
            }            

            using (FileStream fileStream = File.Open(
                filePath,
                FileMode.Open,
                FileAccess.Read,
                FileShare.Read))
            {

                using (TextReader textReader = new StreamReader(fileStream))
                {
                    CDCOXMLSettings.Configuration configuration = CDCOXMLSettings.DeserializeFromXML(textReader);
                    this.sdhServerName = configuration.Domino.SDHServerName;
                    this.databasePath = configuration.Domino.DatabasePath;
                    this.mailServerName = configuration.Domino.MailServerName;
                    this.journalizeToUserMailDb = configuration.Domino.JournalizeToUserMailDb;

                    #region MailItem
                    this.sentOn = configuration.MailItem.X_oSentOn;
                    this.senderName = configuration.MailItem.X_oSenderName;
                    this.senderEmailAddress = configuration.MailItem.X_oSenderEmailAddress;
                    this.sentOnBehalfOfName = configuration.MailItem.X_oSentOnBehalfOfName;
                    this.receivedTime = configuration.MailItem.X_oReceivedTime;
                    this.receivedByName = configuration.MailItem.X_oReceivedByName;
                    this.receivedOnBehalfOfName = configuration.MailItem.X_oReceivedOnBehalfOfName;
                    this.replyRecipientNames = configuration.MailItem.X_oReplyRecipientNames;
                    this.subject = configuration.MailItem.X_oSubject;
                    this.resolvedSenderEmailAdress = configuration.MailItem.X_oResolvedSenderEmailAdress;
                    this.to = configuration.MailItem.X_oTo;
                    this.bcc = configuration.MailItem.X_oBCC;
                    this.cc = configuration.MailItem.X_oCC;
                    this.body = configuration.MailItem.X_oBody;
                    this.bodyFormat = configuration.MailItem.X_oBodyFormat;
                    this.eml = configuration.MailItem.X_oEML;
                    this.msg = configuration.MailItem.X_oMSG;
                    this.entryID = configuration.MailItem.X_oEntryID;
                    this.form = configuration.MailItem.Form;
                    this.saveAsType = configuration.MailItem.SaveAsType;
                    this.conversationID = configuration.MailItem.ConversationID;
                    
                    #endregion MailItem

                    #region ReportItem
                    this.rptItm_BCC = configuration.ReportItem.RptItm_BCC;
                    this.rptItm_Body = configuration.ReportItem.RptItm_Body;
                    this.rptItm_CC = configuration.ReportItem.RptItm_CC;
                    this.rptItm_CreationTime = configuration.ReportItem.RptItm_CreationTime;
                    this.rptItm_EMLBody = configuration.ReportItem.RptItm_EMLBody;
                    this.rptItm_EntryID = configuration.ReportItem.RptItm_EntryID;
                    this.rptItm_Form = configuration.ReportItem.RptItm_Form;
                    this.rptItm_MSGBody = configuration.ReportItem.RptItm_MSGBody;
                    this.rptItm_SaveAsType = configuration.ReportItem.RptItm_SaveAsType;
                    this.rptItm_Subject = configuration.ReportItem.RptItm_Subject;
                    this.rptItm_To = configuration.ReportItem.RptItm_To;
                    this.rptItm_From = configuration.ReportItem.RptItm_From;
                    this.rptItm_ConversationID = configuration.ReportItem.RptItm_ConversationID;
                    this.rptItm_ReceivedByName = configuration.ReportItem.RptItm_ReceivedByName;
                    this.rptItm_ReceivedOnBehalfOfName = configuration.ReportItem.RptItm_ReceivedOnBehalfOfName;
                    this.rptItm_ReplyRecipientNames = configuration.ReportItem.RptItm_ReplyRecipientNames;
                    this.rptItm_ResolvedSenderEmailAdress = configuration.ReportItem.RptItm_ResolvedSenderEmailAdress;
                    this.rptItm_SenderEmailAddress = configuration.ReportItem.RptItm_SenderEmailAddress;
                    this.rptItm_SenderName = configuration.ReportItem.RptItm_SenderName;
                    this.rptItm_SentOnBehalfOfName = configuration.ReportItem.RptItm_SentOnBehalfOfName;
                    
                    #endregion

                    #region MeetingITem
                    this.mtgItm_BCC = configuration.MeetingItem.MtgItm_BCC;
                    this.mtgItm_Body = configuration.MeetingItem.MtgItm_Body;
                    this.mtgItm_CC = configuration.MeetingItem.MtgItm_CC;
                    this.mtgItm_CreationTime = configuration.MeetingItem.MtgItm_CreationTime;
                    this.mtgItm_EMLBody = configuration.MeetingItem.MtgItm_EMLBody;
                    this.mtgItm_EntryID = configuration.MeetingItem.MtgItm_EntryID;
                    this.mtgItm_Form = configuration.MeetingItem.MtgItm_Form;
                    this.mtgItm_MSGBody = configuration.MeetingItem.MtgItm_MSGBody;
                    this.mtgItm_SaveAsType = configuration.MeetingItem.MtgItm_SaveAsType;
                    this.mtgItm_Subject = configuration.MeetingItem.MtgItm_Subject;
                    this.mtgItm_To = configuration.MeetingItem.MtgItm_To;
                    this.mtgItm_From = configuration.MeetingItem.MtgItm_From;
                    this.mtgItm_ConversationID = configuration.MeetingItem.MtgItm_ConversationID;
                    this.mtgItm_ReceivedByName = configuration.MeetingItem.MtgItm_ReceivedByName;
                    this.mtgItm_ReceivedOnBehalfOfName = configuration.MeetingItem.MtgItm_ReceivedOnBehalfOfName;
                    this.mtgItm_ReplyRecipientNames = configuration.MeetingItem.MtgItm_ReplyRecipientNames;
                    this.mtgItm_ResolvedSenderEmailAdress = configuration.MeetingItem.MtgItm_ResolvedSenderEmailAdress;
                    this.mtgItm_SenderEmailAddress = configuration.MeetingItem.MtgItm_SenderEmailAddress;
                    this.mtgItm_SenderName = configuration.MeetingItem.MtgItm_SenderName;
                    this.mtgItm_SentOnBehalfOfName = configuration.MeetingItem.MtgItm_SentOnBehalfOfName;
                    #endregion

                    #region JournalizeSingle
                    this.jnalSgl_CbSDH = configuration.JournalizeSingle.JnalSgl_cbSDH;
                    this.jnalSgl_TbCaseNum = configuration.JournalizeSingle.JnalSgl_tbCaseNum;
                    this.jnalSgl_Lbtitle = configuration.JournalizeSingle.JnalSgl_lbtitle;
                    this.jnalSgl_RbMustReply = configuration.JournalizeSingle.JnalSgl_rbMustReply;
                    this.jnalSgl_TbSeqNum = configuration.JournalizeSingle.JnalSgl_tbSeqNum;
                    this.jnalSgl_CbRplyReq = configuration.JournalizeSingle.JnalSgl_cbRplyReq;
                    this.jnalSgl_CbCaseOfr = configuration.JournalizeSingle.JnalSgl_cbCaseOfr;
                    this.jnalSgl_LbMailRightSelected = configuration.JournalizeSingle.JnalSgl_lbMailRightSelected;
                    this.jnalSgl_TbDocName = configuration.JournalizeSingle.JnalSgl_tbDocName;
                    this.jnalSgl_TbRemarks = configuration.JournalizeSingle.JnalSgl_tbRemarks;
                    this.jnalSgl_CbCaseParts = configuration.JournalizeSingle.JnalSgl_cbCaseParts;
                    this.jnalSgl_CbFreeCat = configuration.JournalizeSingle.JnalSgl_cbFreeCat;
                    this.jnalSgl_LbCaseArea = configuration.JournalizeSingle.JnalSgl_lbCaseArea;
                    this.jnalSgl_LbEdction = configuration.JournalizeSingle.JnalSgl_lbEdction;
                    this.jnalSgl_LbInstitution = configuration.JournalizeSingle.JnalSgl_lbInstitution;
                    this.jnalSgl_LbLeglAspcts = configuration.JournalizeSingle.JnalSgl_lbLeglAspcts;
                    this.jnalSgl_LbEcoAspcts = configuration.JournalizeSingle.JnalSgl_lbEcoAspcts;
                    #endregion

                }
            }
        }
        public override void Save()
        {

        }
    }
    
    public class CDCOSettings : SettingsBase
    {
        public static CDCOSettings SINGLETON = new CDCOSettings();
        public static CDCOSettings Instance
        {
            get { return SINGLETON; }
        }

        private SettingsBase currentSettings;
        
        private CDCOSettings() { }

        private void InitCurrentSettings()
        {

            try
            {
                CDCOFileSettings.Instance.Load();
                this.currentSettings = CDCOFileSettings.Instance;

                this.sdhServerName = this.currentSettings.SDHServerName;
                this.databasePath = this.currentSettings.DatabasePath;

                 return;
            }
            catch (Exception)
            {
                throw new Exception("Failed to initialize CDCOSDHSettings.");
            }
        }

        public void Reload()
        {
            this.currentSettings = null;
            this.Load();
        }

        public override void Load()
        {
            if (this.currentSettings != null)
            {
                this.currentSettings.Load();

                this.sdhServerName = this.currentSettings.SDHServerName;
                this.databasePath = this.currentSettings.DatabasePath;

            }
            else
            {
                this.InitCurrentSettings();
            }
        }
        public override void Save()
        {
        }
       }
    }

